package com.jingdianjichi.wx.handler;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * ClassName:SubscribeMsgHandler
 * Package:com.jingdianjichi.wx.handler
 * Description:
 *
 * @Author fst
 * @Create 2024/10/15 21:57
 * @Version 1.0
 */
@Component
@Slf4j
public class SubscribeMsgHandler implements WxChatMsgHandler
{

    @Override
    public WxChatMsgTypeEnum getMsgType() {
        return WxChatMsgTypeEnum.SUBSCRIBE;
    }

    @Override
    public String dealMsg(Map<String, String> msgmap) {
        log.info("关注事件");
        String fromUserName = msgmap.get("FromUserName");
        String toUserName = msgmap.get("ToUserName");

        String subscrContent="感谢你的关注，欢迎你来社区";

        String replyContent="<xml><ToUserName><![CDATA["+fromUserName+"]]></ToUserName>\n" +
                "<FromUserName><![CDATA["+toUserName+"]]></FromUserName>\n" +
                "<CreateTime>12345678</CreateTime>\n" +
                "<MsgType><![CDATA[text]]></MsgType>\n" +
                "<Content><![CDATA["+subscrContent+"]]></Content>\n"+
                "</xml>";

        return replyContent;
    }
}
